package com.briup.jz.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.briup.jz.bean.OrderLine;
import com.briup.jz.bean.OrderLineExample;
import com.briup.jz.dao.OrderLineMapper;
import com.briup.jz.service.IOrderLineService;
import com.briup.jz.utils.CustomerException;

@Service
public class OrderLineServiceImpl implements IOrderLineService{
@Autowired
	private OrderLineMapper orderLineMapper;
	
	@Override
	public List<OrderLine> query(Long id) {
		OrderLineExample example = new OrderLineExample();
		if(id!=null) {
			example.createCriteria().andIdEqualTo(id);
		}
		List<OrderLine> list = orderLineMapper.selectByExample(example);
		return list;			
	}
	
	@Override
	public void saveOrUpdate(OrderLine orderLine) throws CustomerException {
		if(orderLine.getId()==null) {
			orderLineMapper.insert(orderLine);

		}else {
			orderLineMapper.updateByPrimaryKey(orderLine);
		}																
	}
	
	@Override
	public void deleteById(long id) throws CustomerException {
		OrderLine orderLine = orderLineMapper.selectByPrimaryKey(id);
		if(orderLine==null) {
			throw new CustomerException("要删除的信息不存在");
		}
		orderLineMapper.deleteByPrimaryKey(id);
		
	}
}
